#ifndef GAME_H
#define GAME_H

#include "Wrapper\CSGD_Direct3D.h"
#include "Wrapper\CSGD_DirectInput.h"
#include "Wrapper\CSGD_FModManager.h"
#include "Wrapper\CSGD_TextureManager.h"
#include "GameStates\BaseState.h"

class LevelState;

class Game
{
public:
	// Singleton Accessor
	static Game* GetInstance();
	
	void Init(HWND _hWnd, HINSTANCE _hInstance, int _screenWidth, int _screenHeight, bool _isWindowed, bool _isVsync);
	bool Main();		// Returns false to quit game
	void Exit();

	// Game State Control
	void PushState(BaseState* _state);
	void PopState();
	void ChangeState(BaseState* _state);
	void ClearStates();

	////////////////////////////////////////////
	// ACCESSORS
	////////////////////////////////////////////
	int GetScreenWidth()				{return screenWidth;}
	int GetScreenHeight()				{return screenHeight;}
	bool GetIsWindowed()				{return isWindowed;}
	float GetTotalElapsedTime()			{return totalElapsedTime;}
	POINT GetCursorPosition() const		{return cursorPos;}

	////////////////////////////////////////////
	// MUTATORS
	////////////////////////////////////////////
	void SetScreenWidth(int _width)			{screenWidth = _width;}
	void SetScreenHeight(int _height)		{screenHeight = _height;}
	void SetIsWindowed(bool _status)		{isWindowed = _status;}
	void SetCursorPosition(POINT _value)	{cursorPos = _value;}

private:
	Game();
	~Game();
	Game(const Game &obj);
	Game& operator=(const Game &obj);

	// Utility Functions
	bool Input();
	void Update();
	void Render();

private:
	//Singletons
	CSGD_Direct3D*			d3d;
	CSGD_TextureManager*	texManager;
	CSGD_DirectInput*		dirInput;
	CSGD_FModManager*		fModManager;

	// Timers
	DWORD currTimeStamp;
	DWORD prevTimeStamp;
	float currElapsedTime;
	float totalElapsedTime;

	// General
	int screenWidth;
	int screenHeight;
	POINT cursorPos;
	bool isWindowed;
	vector<BaseState*> gameStates;

	LevelState* currLevel;

};

#endif	// GAME_H